package com.eduran.tuts.jfundamentals.controller;

import com.eduran.tuts.jfundamentals.model.Account;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.controlsfx.dialog.Dialog;
import org.controlsfx.dialog.Dialogs;

import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;

/**
 * Created by eduran on 19.09.2014.
 */
public class Controller implements Initializable {
    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    @FXML private TextField txtFieldAccountName;
    @FXML private Button btnTestAccount;
    @FXML private HTMLEditor htmlTestEditor;

    public void testAccount(){
        Account account = new Account(txtFieldAccountName.getText());
        htmlTestEditor.setHtmlText(account.getName());
        Stage stage = new Stage();
        stage.setX(0.0);
        stage.setY(0.0);
        stage.getModality();
        Optional<String> response = Dialogs.create().owner(stage).title("Acount Test").message("Please enter the account name:").showTextInput();
        if (response.isPresent()) {
            System.out.println("Account Name: " + response.get());
        }
    }

    public void action(){

    }
}
